package com.durablemethods.tsmserver;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.durablemethods.tsmserver.home.PositionHome;
import com.durablemethods.tsmserver.home.TradeRevenueHome;
import com.durablemethods.tsmserver.model.Position;
import com.durablemethods.tsmserver.model.TraderTradeRevenue;

public class TradeRevenueServlet extends HttpServlet {
	private TradeRevenueHome tradeRevenueHome = new TradeRevenueHome();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)	throws ServletException, IOException {
		resp.setContentType("text/plain");
		List<TraderTradeRevenue> revenues = tradeRevenueHome.getTradeRevenues();
		resp.getWriter().println("Trader,Revenue,Transactions");
		for (TraderTradeRevenue revenue : revenues) {
			String format = String.format("%s,%s,%s", revenue.getTrader(), revenue.getRevenue(), revenue.getTransactions());
			resp.getWriter().println(format);
		}
	}

}
